import axios from 'axios';
//
const baseUrl = ''
class HttpRequest {
    constructo(baseUrl){
        this.baseUrl = baseUrl
    }

    getInsideConfig(){
        const config = {
            baseUrl:this.baseUrl,
            header:{}
        }
        return config
    }

    interceptors(instance) {
        instance.interceptors.request.use(function (config) {
      
          return config;
        }, function (error) {
    
          return Promise.reject(error);
        });
    
    
        instance.interceptors.response.use(function (response) {
          const { data, code } = response.data
          if (code == 200) {
            return data
          } else {
            // 
          }
       
    
        }, function (error) {
          
          return Promise.reject(error);
        });
      }
      request(options) {
        const instance = axios.create()
        options = { ...this.getInsideConfig(), ...options }
        this.interceptors(instance)
        return instance(options)
      }
}
export default new HttpRequest(baseUrl)